import http from '@/utils/http'

const BASE_URL = '/card/businessCardVisitorRecord'

export interface BusinessCardVisitorRecordResp {
  id: string
  cardId: string
  openId: string
  avatar:string
  nickname:string
  gender:Number
  country:string
  province:string
  city:string
  cardName:string
  visitorTime: string
  duration: string
  ipAddress: string
  deviceType: string
  operatingSystem: string
  actions: string
  description: string
  createTime: string
  createUser: string
  updateTime: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface BusinessCardVisitorRecordDetailResp {
  id: string
  cardId: string
  openId: string
  avatar:string
  nickname:string
  gender:Number
  country:string
  province:string
  city:string
  cardName:string
  visitorTime: string
  duration: string
  ipAddress: string
  deviceType: string
  operatingSystem: string
  actions: string
  description: string
  createTime: string
  createUser: string
  updateTime: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface BusinessCardVisitorRecordQuery {
  openId: string
  sort: Array<string>
}
export interface BusinessCardVisitorRecordPageQuery extends BusinessCardVisitorRecordQuery, PageQuery {}

/** @desc 查询微信名片访问记录列表 */
export function listBusinessCardVisitorRecord(query: BusinessCardVisitorRecordPageQuery) {
  return http.get<PageRes<BusinessCardVisitorRecordResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询微信名片访问记录详情 */
export function getBusinessCardVisitorRecord(id: string) {
  return http.get<BusinessCardVisitorRecordDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增微信名片访问记录 */
export function addBusinessCardVisitorRecord(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改微信名片访问记录 */
export function updateBusinessCardVisitorRecord(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除微信名片访问记录 */
export function deleteBusinessCardVisitorRecord(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出微信名片访问记录 */
export function exportBusinessCardVisitorRecord(query: BusinessCardVisitorRecordQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
